/*
* How to spool a Picture to a File
*/
// Assumes inclusion of
pascal void PutPICTData(Ptr dataPtr, short byteCount); void PictOut(void);
short globalRef;
pascal void PutPICTData(Ptr dataPtr, short byteCount) {
long longCount;
longCount = byteCount;
if (FSWrite( globalRef, &longCount, dataPtr) != noErr) if (pHand2) /* Help QD take care of oddness in the picture */
(**pHand2).picSize += longCount;
}
void PictOut()
{
short i,
vrefnum;
Point where; /* where to display dialog */ long longCount,
longZero;
CGrafPtr myPortPtr,
oldPort;
pictRect;
myPortPtr = &myPort; /* initialize */
where.h = 20;
SFPutFile(where, "\pSave picture as: ", "\puntitled", nil, &reply); if (!reply.good)
if (err != dupFNErr && err != noErr)
if (err)
pHand2 = nil;
myPortPtr->grafProcs = &myProcs;
myProcs.putPicProc = (Ptr)&PutPICTData; longZero = 0;
longCount = 4;
for (i = 1; i <= (512 + sizeof(Picture)) / 4; ++i)
err = FSWrite ( globalRef, &longCount, &longZero); if (err)
if (SetFPos( globalRef, fsFromStart, 512) != noErr) if (FSWrite( globalRef, &longCount, *pHand2) != noErr) myPortPtr->grafProcs = nil;
} /* OutPICT */
main()
{
PictOut();
}